/*
 * Created by SharpDevelop.
 * User: Dario
 * Date: 15-11-2006
 * Time: 14:34
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using MySql.Data.MySqlClient;

namespace GAH
{
	/// <summary>
	/// Description of ayudaMalla.
	/// </summary>
	public partial class ayudaMalla
	{
		private TextBox pramo;
		private TextBox pnivel;
		private TextBox phora;
		private TextBox pllave;
		
		public string Ramo
		{   
			set { this.pramo.Text = value;}
			get { return this.pramo.Text;}
		}
		public string Nivel{
			set { this.pnivel.Text = value;}
			get { return this.pnivel.Text;}
		}
		public string Hora{
			set { this.phora.Text = value;}
			get { return this.phora.Text;}
		}
		public string Llave{
			set { this.pllave.Text = value;}
			get { return this.pllave.Text;}
		}
		
			
		public ayudaMalla(ref TextBox Ramo,ref TextBox Nivel,ref TextBox Hora,ref TextBox Llave)
		{
			this.pramo		= Ramo;
			this.pnivel		= Nivel;
			this.phora		= Hora;
			this.pllave		= Llave;
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
		}
		
		void DataGrid1Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
		{
			
		}
		
		 
		void ayudaMallaLoad(object sender, System.EventArgs e)
		{
			negocio neg = new negocio();
			
		   	MySqlDataReader reader = neg.select("SELECT * FROM mallacurso ");
		   	
	   		Grilla.Columns.Add("colRamo"		, "Asignatura");
	   		Grilla.Columns.Add("colNivel"		, "Nivel");
	   		Grilla.Columns.Add("colHora"		, "Horas");
	   		Grilla.Columns.Add("colidRamo"		, "Llave");
	   		Grilla.Columns["colidRamo"].Visible = false;     // Columna colidRamo no visible.
	   		
	   		
	   		int Fila = 0;
		   	while (reader.Read())	
		   	{
		   		Grilla.Rows.Add();
		   		//Ramo
		   		Grilla.Rows[Fila].Cells[0].Value = reader["Ramo_idRamo"].ToString();
		   		//Nivel
		   		Grilla.Rows[Fila].Cells[1].Value = reader["Nivel_idNivel"].ToString();
		   		//Horas
		   		Grilla.Rows[Fila].Cells[2].Value = reader["Horas"].ToString();
		   		// Llave
		   		Grilla.Rows[Fila].Cells[3].Value = reader["idMallaCurso"].ToString();
		   		Fila++;
		   	}
		   	neg.cerrar();
		}
		
		void GrillaCellContentClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
		{
			int Fila    = e.RowIndex;
			//Ramo
			this.pramo.Text		= Grilla.Rows[Fila].Cells[0].Value.ToString();
			//Nivel
			this.pnivel.Text	= Grilla.Rows[Fila].Cells[1].Value.ToString();
			//Horas
			this.phora.Text		= Grilla.Rows[Fila].Cells[2].Value.ToString();
			//Llave
			this.pllave.Text	= Grilla.Rows[Fila].Cells[3].Value.ToString();
			this.Close();
		}
	}
}
